/*
 * analizador lexico del interprete de maquina sam
 */

%{
  #include "sintax.h"

  int yywrap(void); 
  void yycomment( char * mat) ;
%}

digit                    [0-9]
intro                    [\n]
white_space              [ \t]
menos                    [-]
other                    .
%option yylineno
%%

{white_space}+              ;

"/*"                        yycomment("*/");


{menos}*{digit}+                    { yylval.valor = strtol( yytext, (char**)0, 10);
                              return NUM;
                            }

{intro}                     return '\n';
{other}                     return yytext[0];

%%



void yyerror(char *s){
  printf("%s\n", s);
} /* yyerror */

void yycomment( char * mat) {
  int c;
  char *cp;

  for (cp = mat; *cp != 0; ) {
    c = input();
    if (c == EOF) {
      yyerror("end of file in comment");
      break;
    }
    if (c != *cp++) {
      cp = mat;
      if (c == *cp)
      	cp++;
    }
  } /* for */
} /* yycomment */

int yywrap(void){
  return 1;
}
